package com.bdqn.dao;

import com.bdqn.pojo.NewType;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class NewTypeDao {

    public static NewType getObj(String id) throws Exception {
       NewType obj=new NewType();
        ResultSet  set= BaseDao.getResultSet("select * from newtype where id=?",new Object[]{id});
        if (set.next())
        {
             obj=new NewType(
                    set.getInt("id"),
                    set.getString("name")
                    ,""
            );

        }
        BaseDao.close();
        return obj;
    }

    public static ArrayList<NewType> getlist() throws Exception {
        ArrayList<NewType> list=new ArrayList<NewType>();
        ResultSet  set= BaseDao.getResultSet("select * from newtype",new Object[]{});
        while (set.next())
        {
            NewType obj=new NewType(
                    set.getInt("id"),
                    set.getString("name")
                    ,""
            );
            list.add(obj);
        }
        BaseDao.close();
        return list;
    }
}
